package com.baturu.vin.benz.dal.dao;

import com.baturu.vin.benz.dto.BenzExtendPartsRelationDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author jiangxinlei
 * @Time 2017/4/17.
 */
public interface BenzExtendPartsRelationDAO {

    @Select({"SELECT DISTINCT partsCode,btrPartsName,groupName,subgrpName,NOUN,DESCIDX FROM `tmp_benz_parts_mapping_epcname`",
            "where LENGTH(DESCIDX) >9;"})
    List<BenzExtendPartsRelationDTO> findPartsMappingDes();


    @Insert({"<script>insert into tmp_benz_parts_mapping_epcname_description values",
            "<foreach item='dto' index='index' collection='dtos' open='' separator=',' close='' >",
            "(#{dto.partsCode},#{dto.btrPartsName},#{dto.groupName},#{dto.subgrpName},#{dto.NOUN},#{dto.description})",
            "</foreach> </script>"})
    int adddescription(@Param("dtos") List<BenzExtendPartsRelationDTO> dtos);


    @Select({"select partsCode, btrPartsName, epcName from tmp_benz_parts_mapping_epcname_short"})
    List<BenzExtendPartsRelationDTO> findepcnames();

    @Insert({"<script>insert ignore into tmp_benz_parts_mapping_mayright(partsCode,btrPartsName,epcName) values",
            "<foreach item='dto' index='index' collection='dtos' open='' separator=',' close='' >",
            "(#{dto.partsCode},#{dto.btrPartsName},#{dto.epcName})",
            "</foreach> </script>"})
    int addmayright(@Param("dtos") List<BenzExtendPartsRelationDTO> dtos);

}
